/*
 * @file     g_exit.h
 * @brief    source file for setting exit
 *
 * Change Logs:
 * Date            Author             Version        Notes
 * 2022-02-25      wsy                V1.0.0         the first version
 */

#ifndef __G_DAC_H__
#define __G_DAC_H__
#include "g_1903.h"

#define DAC_SINGLE	(0)
#define DAC_CYCLE   (1)

#define   AUDIO_BASEADDR            (0xfb900)
#define   DAC_CTRL                  *(volatile uint8_t*) (AUDIO_BASEADDR + 0x00)
#define   DAC_VOX_WINDOW            *(volatile uint8_t*) (AUDIO_BASEADDR + 0x01)
#define   DAC_THRESHOLD_GAIN        *(volatile uint16_t*)(AUDIO_BASEADDR + 0x02)
#define   DAC_COEF_A                *(volatile uint32_t*)(AUDIO_BASEADDR + 0x04)
#define   DAC_CAL_WINDOW            *(volatile uint8_t*) (AUDIO_BASEADDR + 0x07)
#define   DAC_THRESHOLD_MAX         *(volatile uint16_t*)(AUDIO_BASEADDR + 0x08)
#define   DAC_VOX_CTRL              *(volatile uint8_t*) (AUDIO_BASEADDR + 0x0a)
#define   DAC_VOL_TEST              *(volatile uint8_t*) (AUDIO_BASEADDR + 0x0b)

#define   DAC_RECOVER_DETECT        *(volatile uint8_t*) (AUDIO_BASEADDR + 0x0c)
#define   DAC_THRESHOLD_UPDATE_VAL  *(volatile uint8_t*) (AUDIO_BASEADDR + 0x10)
#define   DAC_THRESHOLD_VAL         *(volatile uint8_t*) (AUDIO_BASEADDR + 0x12)
#define   DAC_STATUS                *(volatile uint8_t*) (AUDIO_BASEADDR + 0x14)

#define   DAC_FS_DIV                *(volatile uint16_t*)(AUDIO_BASEADDR + 0x20)
#define   DAC_DMA_EN                *(volatile uint8_t*) (AUDIO_BASEADDR + 0x22)
#define   DAC_DMA_SADDR             *(volatile uint32_t*)(AUDIO_BASEADDR + 0x24)
#define   DAC_DMA_EADDR             *(volatile uint32_t*)(AUDIO_BASEADDR + 0x28)
#define   DAC_DMA_STATUS            *(volatile uint32_t*)(AUDIO_BASEADDR + 0x2c)
#define   DAC_WATER_LEVEL           *(volatile uint32_t*)(AUDIO_BASEADDR + 0x30)
#define   DAC_DOEN                  *(volatile uint32_t*)(AUDIO_BASEADDR + 0x34)

#define    DAC_CTRL_ENABLE          (0)
#define    DAC_CTRL_CLK_EN          (1)
#define    DAC_CTRL_RECOVER_DIS     (2)
#define    DAC_CTRL_OUT_CTRL        (3)
#define    DAC_CTRL_MUTE            (4)
void G_DAC_Init(uint8_t volume,G_FunctionalState IntrState,uint16_t water_level, uint8_t sample_multiple);
void G_DAC_Out(uint8_t mode,uint8_t *buf, uint32_t len);
void G_DAC_Off(void);

#endif
